package cn.edu.zafu.bigdata.lwg;

class StaticDemo {
    static int count = 0;
    int id;

    static {
        System.out.println("Static block executed");
        count = 0;
    }

    {
        System.out.println("Instance block executed");
        id = count;
        count++;
    }

    public StaticDemo() {
        System.out.println("Constructor executed for ID: " + id);
    }

    public static void displayCount() {
        System.out.println("Total instances created: " + count);
    }
}

public class TestStaticDemo {
    public static void main(String[] args) {
        StaticDemo s1 = new StaticDemo();
        StaticDemo s2 = new StaticDemo();
        StaticDemo s3 = new StaticDemo();

        StaticDemo.displayCount();

    }
}
